# -*- coding: utf-8 -*-
import urllib2
import lxml.etree

url = 'http://www.weather.com.cn/html/weather/101010100.shtml'
with open('../htmlfiles/weather.html','w') as fs:
    page = urllib2.urlopen(url)
    print >> fs, page.read()
    fs.close()
    
with open('../htmlfiles/weather.html','r') as f:
    parser = lxml.etree.HTMLParser(encoding='utf8')
    doc = lxml.etree.parse(f, parser)
    xp = '/html/body/div[4]/div/div/div[4]/div/span'
    result = doc.xpath(xp)
    print len(result) #, dir(result)
    print result[0].text.strip()
    f.close() 
    